HTML DOM Input FileUpload files Property 您所在的位置:网站首页 Upload a File Using JavaScript HTML DOM Input FileUpload files Property

HTML DOM Input FileUpload files Property

2024-07-08 14:42| 来源: 网络整理| 查看: 265

Input FileUpload files Property

❮ Input FileUpload Object

Example

Select one or more files with the file upload button, and display some information about the selected file(s):

var x = document.getElementById("myFile");var txt = "";if ('files' in x) {  if (x.files.length == 0) {    txt = "Select one or more files.";  } else {    for (var i = 0; i < x.files.length; i++) {       txt += "" + (i+1) + ". file";      var file = x.files[i];       if ('name' in file) {        txt += "name: " + file.name + "";       }      if ('size' in file) {        txt += "size: " + file.size + " bytes ";       }    }  } } document.getElementById ("demo").innerHTML = txt; Try it Yourself » Description

The files property returns a FileList object, representing the file or files selected with the file upload button.

Through the FileList object, you can get the the name, size and the contents of the files

This property is read-only.

Browser Support Property files Yes 10.0 Yes Yes Yes Syntax fileuploadObject.files Technical Details Return Value: A FileList object that represents the selected file or files ❮ Input FileUpload Object ★ +1   W3schools Pathfinder Track your progress - it's free!   Log in Sign Up


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有